#ifndef __CDBG_H__ //class of Debug module
#define __CDBG_H__

#ifdef _WIN32_WCE
	#define GENsprintf   wsprintf
	#define GENstrlen	wcslen
	#define GENstrncmp	wcsncmp
	#define GENItoa		_itow
	#define GENatoi		_wtoi
#else
	#define GENsprintf	sprintf
	#define GENstrlen	strlen
	#define GENstrncmp	strncmp
	#define GENItoa		_itoa
	#define GENatoi		atoi
#endif

#define		ENABLE_DBGOUT			// whether write  log
#ifdef ENABLE_DBGOUT
	#define		DBG_OUT_TO_FILE		//Write debug string(not read/write string)  to file.									//If it is not defined, then output debug string to message box
#endif

#define		MAX_LOG_STRING	  320	//max log string to write

enum 
{
	CDBG_OK,						//Success
	CDBG_OPEN_FILE_FAIL,			//open com port fail, maybe the port is already by other ap
	CDBG_INVALID_HANDLE,			//file handle is invalid
	CDBG_FAIL,						//other errors
} ; 


class CDBG
{
private:
    HANDLE	m_hLogFile;

public:
	CDBG();
   // destructor
	~CDBG() {m_hLogFile	=	INVALID_HANDLE_VALUE;};
	int WriteToLog  (BYTE* bWriteString , DWORD nRequestLen = 0);
	int DBGOut(char* format, ...);
	int OpenLogFile (TCHAR *szLogPathName, bool bIfOverWrite );
	int CloseLogFile ();
};

#endif